import axios from 'axios'
let defaultUrl = 'http://47.97.212.129:3601'
// let defaultUrl = ''
export default function ajax(url = '', data = {}, type = 'GET') {
    if (type === 'GET') {
        let dataStr = ''
        Object.keys(data).forEach(key => {
            dataStr += key + '=' + data[key] + '&'
        })
        if (dataStr !== '') {
            dataStr = dataStr.substring(0, dataStr.length - 1)
        }
        url = url + '?' + dataStr
        return axios.get( defaultUrl + url)
    } else {
        return axios.post( defaultUrl + url, data)
    }
}